home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / netinet / in.m < prev    next >
Encoding:
Text File  |  2002-10-28  |  7.0 KB  |  198 lines

  1. /*
  2.  * $Id: in.h,v 1.6 1993/06/04 11:16:15 jraja Exp $
  3.  *
  4.  * HISTORY
  5.  * $Log: in.h,v $
  6.  * Revision 1.6  1993/06/04  11:16:15  jraja
  7.  * Fixes for first public release.
  8.  *
  9.  * Revision 1.5  1993/04/13  22:07:58  jraja
  10.  * Added inclusion of sys/param.h, which include htons() et al, since many
  11.  * BSD programs think that they should be included from here.
  12.  *
  13.  * Revision 1.4  93/03/06  02:14:28  02:14:28  jraja (Jarno Tapio Rajahalme)
  14.  * Made INADDR_ANY visible in AmiTCP even in KERNEL, since library functions
  15.  * need it.
  16.  * 
  17.  * Revision 1.3  93/03/03  22:07:51  22:07:51  jraja (Jarno Tapio Rajahalme)
  18.  *  Changed explicit prototypes back.
  19.  * 
  20.  * Revision 1.2  93/03/03  21:55:25  21:55:25  jraja (Jarno Tapio Rajahalme)
  21.  * Added #ifndef to prevent multiple inclusion.
  22.  * 
  23.  * Revision 1.1  92/11/17  16:47:45  16:47:45  jraja (Jarno Tapio Rajahalme)
  24.  * Initial revision
  25.  * 
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
  31.  * All rights reserved.
  32.  *
  33.  * Redistribution and use in source and binary forms, with or without
  34.  * modification, are permitted provided that the following conditions
  35.  * are met:
  36.  * 1. Redistributions of source code must retain the above copyright
  37.  *    notice, this list of conditions and the following disclaimer.
  38.  * 2. Redistributions in binary form must reproduce the above copyright
  39.  *    notice, this list of conditions and the following disclaimer in the
  40.  *    documentation and/or other materials provided with the distribution.
  41.  * 3. All advertising materials mentioning features or use of this software
  42.  *    must display the following acknowledgement:
  43.  *      This product includes software developed by the University of
  44.  *      California, Berkeley and its contributors.
  45.  * 4. Neither the name of the University nor the names of its contributors
  46.  *    may be used to endorse or promote products derived from this software
  47.  *    without specific prior written permission.
  48.  *
  49.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59.  * SUCH DAMAGE.
  60.  *
  61.  *      @(#)in.h        7.11 (Berkeley) 4/20/91
  62.  */
  63.  
  64. /*
  65.  * Macros for network/external number representation conversion.
  66.  */
  67. #define ntohl(x)        (x)
  68. #define ntohs(x)        (x)
  69. #define htonl(x)        (x)
  70. #define htons(x)        (x)
  71.  
  72. #define NTOHL(x)        (x)
  73. #define NTOHS(x)        (x)
  74. #define HTONL(x)        (x)
  75. #define HTONS(x)        (x)
  76.  
  77. /*
  78.  * Constants and structures defined by the internet system,
  79.  * Per RFC 790, September 1981.
  80.  */
  81.  
  82. /*
  83.  * Protocols
  84.  */
  85. #define IPPROTO_IP              0               /* dummy for IP */
  86. #define IPPROTO_ICMP            1               /* control message protocol */
  87. #define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
  88. #define IPPROTO_TCP             6               /* tcp */
  89. #define IPPROTO_EGP             8               /* exterior gateway protocol */
  90. #define IPPROTO_PUP             12              /* pup */
  91. #define IPPROTO_UDP             17              /* user datagram protocol */
  92. #define IPPROTO_IDP             22              /* xns idp */
  93. #define IPPROTO_TP              29              /* tp-4 w/ class negotiation */
  94. #define IPPROTO_EON             80              /* ISO cnlp */
  95.  
  96. #define IPPROTO_RAW             255             /* raw IP packet */
  97. #define IPPROTO_MAX             256
  98.  
  99.  
  100. /*
  101.  * Local port number conventions:
  102.  * Ports < IPPORT_RESERVED are reserved for
  103.  * privileged processes (e.g. root).
  104.  * Ports > IPPORT_USERRESERVED are reserved
  105.  * for servers, not necessarily privileged.
  106.  */
  107. #define IPPORT_RESERVED         1024
  108. #define IPPORT_USERRESERVED     5000
  109.  
  110. /*
  111.  * Internet address (a structure for historical reasons)
  112.  */
  113. OBJECT in_addr
  114.     s_addr:ULONG
  115.  
  116.  
  117. /*
  118.  * Definitions of bits in internet address integers.
  119.  * On subnets, the decomposition of addresses to host and net parts
  120.  * is done according to subnet mask, not the masks here.
  121.  */
  122. #define IN_CLASSA(i)            (((i) & $80000000) = 0)
  123. #define IN_CLASSA_NET           $ff000000
  124. #define IN_CLASSA_NSHIFT        24
  125. #define IN_CLASSA_HOST          $00ffffff
  126. #define IN_CLASSA_MAX           128
  127.  
  128. #define IN_CLASSB(i)            (((i) & $c0000000) = $80000000)
  129. #define IN_CLASSB_NET           $ffff0000
  130. #define IN_CLASSB_NSHIFT        16
  131. #define IN_CLASSB_HOST          $0000ffff
  132. #define IN_CLASSB_MAX           65536
  133.  
  134. #define IN_CLASSC(i)            (((i) & $e0000000) = $c0000000)
  135. #define IN_CLASSC_NET           $ffffff00
  136. #define IN_CLASSC_NSHIFT        8
  137. #define IN_CLASSC_HOST          $000000ff
  138.  
  139. #define IN_CLASSD(i)            (((i) & $f0000000) = $e0000000)
  140. #define IN_MULTICAST(i)         IN_CLASSD(i)
  141.  
  142. #define IN_EXPERIMENTAL(i)      (((i) & $e0000000) = $e0000000)
  143. #define IN_BADCLASS(i)          (((i) & $f0000000) = $f0000000)
  144.  
  145. #define INADDR_ANY              $00000000
  146. #define INADDR_BROADCAST        $ffffffff      /* must be masked */
  147. #define INADDR_NONE             $ffffffff              /* -1 return */
  148.  
  149.  
  150. #define IN_LOOPBACKNET          127                     /* official! */
  151.  
  152. /*
  153.  * Socket address, internet style.
  154.  */
  155. OBJECT sockaddr_in
  156.     sin_len:UBYTE,
  157.     sin_family:UBYTE,
  158.     sin_port:UWORD,
  159.     sin_addr:in_addr,
  160.     sin_zero[8]:BYTE
  161.  
  162.  
  163. /*
  164.  * Structure used to describe IP options.
  165.  * Used to store options internally, to pass them to a process,
  166.  * or to restore options retrieved earlier.
  167.  * The ip_dst is used for the first-hop gateway when using a source route
  168.  * (this gets put into the header proper).
  169.  */
  170. OBJECT ip_opts
  171.     ip_dst:in_addr,         /* first hop, 0 w/o src rt */
  172.     ip_opts[40]:BYTE            /* actually variable in size */
  173.  
  174.  
  175. /*
  176.  * Options for use with [gs]etsockopt at the IP level.
  177.  * First word of comment is data type; bool is stored in int.
  178.  */
  179. #define IP_OPTIONS      1       /* buf/ip_opts; set/get IP per-packet options */
  180. #define IP_HDRINCL      2       /* int; header is included with data (raw) */
  181. #define IP_TOS          3       /* int; IP type of service and precedence */
  182. #define IP_TTL          4       /* int; IP time to live */
  183. #define IP_RECVOPTS     5       /* bool; receive all IP options w/datagram */
  184. #define IP_RECVRETOPTS  6       /* bool; receive IP options for response */
  185. #define IP_RECVDSTADDR  7       /* bool; receive IP dst addr w/datagram */
  186. #define IP_RETOPTS      8       /* ip_opts; set/get IP per-packet options */
  187.  
  188. /*
  189. #ifdef KERNEL
  190. struct in_addr in_makeaddr(u_long net,
  191.                            u_long host);
  192. u_long in_netof(struct in_addr in);
  193. u_long in_lnaof(struct in_addr in);
  194. #endif
  195. */
  196.  
  197.  
  198.